package org.terramagnet.http.signature;

import org.terramagnet.http.signature.impl.InstanceCachedSignature;
import org.terramagnet.http.signature.impl.Md5SignatureAlgorithm;

/**
 * 签名方法工厂. 用来获取指定的签名方法.
 *
 * @author lip
 */
public class SignerFactory {

	private static final Signer md5Cache = new InstanceCachedSignature(Md5SignatureAlgorithm.class);

	/**
	 * 获得指定名字的签名方法. 不支持的签名方法时返回{@code null}.
	 *
	 * @param name 签名方法名
	 * @return 签名方法或{@code null}.
	 */
	public static Signer getSigner(String name) {
		if ("md5".equalsIgnoreCase(name)) {
			return md5Cache;
		} else {
			return null;
		}
	}
}
